package com.shxt.service.impl;

import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.shxt.mapper.RoleMapper;
import com.shxt.mapper.Role_link_menuMapper;
import com.shxt.mapper.UserMapper;
import com.shxt.model.Role;
import com.shxt.service.RoleService;
@Service
public class RoleServiceImpl implements RoleService{
	@Autowired
	private RoleMapper roleMapper;
	@Autowired
	private UserMapper userMapper;
	@Autowired
	private Role_link_menuMapper role_link_menuMapper;
	@Override
	public int delete(Integer role_id ) {
		// TODO Auto-generated method stub
		Role role = new Role();
		role.setRole_id(role_id);
		//更改用户的权限
		//删除菜单和权限的联系
		this.userMapper.mdiUserByRole_Id(role);
		this.role_link_menuMapper.deleteByRole_id(role);
		return this.roleMapper.delete(role_id);
	}

	@Override
	public int add(Role role ) {
		// TODO Auto-generated method stub
		return this.roleMapper.add(role);
	}

	@Override
	public Role load(Integer role_id ) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int update(Role role ) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public List<Role> listRole(Map<String , Object> map) {

		return this.roleMapper.listRole(map);
	}

	@Override
	public int count(Map<String , Object> map ) {

		return this.roleMapper.count(map);
	}

	@Override
	public int checkRole_Name(Role role ) {

		return this.roleMapper.checkRole_Name(role);
	}



}
